<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/admin/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/admin/css/font.css">
    <link rel="stylesheet" href="/admin/css/xadmin.css">
    <script src="/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/admin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="/index/index">首页</a>
        <a>
          <cite>管理员列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input class="layui-input" placeholder="开始日" name="start" id="start">
            <input class="layui-input" placeholder="截止日" name="end" id="end">
            <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input"
                   id="username">
            <button class="layui-btn" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>

    <xblock>
        <button class="layui-btn layui-btn-danger" id="deleteButton"><i class="layui-icon"></i>批量删除
        </button>
        <button class="layui-btn" onclick="x_admin_show('添加用户','/student/add')"><i class="layui-icon"></i>添加
        </button>
        <a class="layui-btn" title="下载模板" href="/student/downloadModel">下载模板</a>
        <a class="layui-btn" title="下载模板" href="/student/export">导出数据为Excel</a>
        <form action="/student/DoImportExcel" style="margin-top: 10px;" method="post" enctype="multipart/form-data"
              class="layui-form">
            <div class="layui-input-inline" id="image">
                <input type="file" name="excelFile" id="file" inputmode="post" multiple="true" lay-verify="required"
                       placeholder="导入Excel" autocomplete="off" class="layui-input"
                       accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel">
            </div>
            <button class="layui-btn" lay-filter="add" lay-submit="">
                导入Excel
            </button>
        </form>

        <span class="x-right" style="line-height:40px" th:text="'共有数据：'+${pageInfo.total}+'条'"></span>
    </xblock>

    <table class="layui-table">
        <thead>
        <th>
            <input class="layui-unselect header layui-form-checkbox" lay-skin="primary"
                   type="checkbox" id="SelectAll" onclick="selectAll();"/></th>
        </th>
        <th>学号</th>
        <th>姓名</th>
        <th>身份证</th>
        <th>学院</th>
        <th>专业</th>
        <th>班级</th>
        <th>状态</th>
        <th>入学时间</th>
        <th>操作</th>
        </thead>
        <tbody>
        <div th:each="stu:${pageInfo.list}">
            <tr>
                <td>
                    <input type="checkbox" name="checkbox" th:value="${stu.stuNo}">
                </td>
                <td name="id" th:text="${stu.stuNo}"></td>
                <td th:text="${stu.stuName}"></td>
                <!--                <td>-->
                <!--                    <img th:src="@{'/admin/images/upload/'+${stu.profile}}">-->
                <!--                </td>-->
                <td th:text="${stu.stuIdCard}"></td>
                <td th:text="${stu.college}"></td>
                <td th:text="${stu.major}"></td>
                <td th:text="${stu.classNum}"></td>
                <td class="td-status">
                    <span class="layui-btn layui-btn-normal layui-btn-mini" th:text="${stu.stuState}"></span>
                </td>
                <td th:text="${#temporals.format(stu.stuRepoTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                <td class="td-manage">
                    <a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">
                        <i class="layui-icon">&#xe601;</i>
                    </a>
                    <a title="编辑" class="editButton" th:url="'/student/edit/'+ ${stu.stuNo}"
                       th:onclick="|x_admin_show('编辑',this.getAttribute('url'))|" href="javascript:;">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除" th:href="@{/student/del(id=${stu.stuNo})}">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
        </div>
        </tbody>
    </table>
    <div class="page">
        <a th:href="@{/student/list}" style="margin: -5px">首页</a>
        <span>
            <a class="prev" th:href="@{/student/list(page=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}"
               style="margin: -5px"><<</a>
            <span th:each="nav:${pageInfo.navigatepageNums}" style="margin: -5px">
                <a th:href="'/student/list?page='+${nav}+'&size='+${pageInfo.pageSize}" th:text="${nav}"
                   th:if="${nav != pageInfo.pageNum}"></a>
                <span th:if="${nav == pageInfo.pageNum}" th:text="${nav}"></span>
            </span>
            <a class="next"
               th:href="@{/student/list(page=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}"
               style="margin: -5px">>></a>
        </span>
        <a th:href="@{/student/list(page=${pageInfo.pages})}" style="margin: -5px">尾页</a>
    </div>
</div>
<script>
    //全选(全不选)
    function selectAll() {
        //如果选择全选按钮
        if ($("#SelectAll").is(":checked")) {
            $(":checkbox").prop("checked", true);//所有选择框都选中
        } else {  //如果没有选择全选按钮
            $(":checkbox").prop("checked", false); //全部不选中
        }
    }

    //批量删除
    $("#deleteButton").on("click", function () {
        //判断至少写了一项
        var checkedNum = $("input[name='checkbox']:checked").length;
        if (checkedNum == 0) {
            alert("请至少选择一项!");
            return false;
        }
        //创建数组,存储选择的id
        var checkedList = new Array();
        $("input[name='checkbox']:checked").each(function () {
            //把当前选中的复选框的id存入数组中
            checkedList.push($(this).val());
        });
        var str = checkedList.join(",");
        console.log(checkedList);
        console.log(str);
        //提示删除
        var flag = confirm("确认要删除这" + checkedList.length + "条数据吗?")
        if (flag) {
            //传参,后端继续进行删除操作,传到后端的是一个String数组
            window.location.href = "http://127.0.0.1:8080/student/dels?ids=" + str;
        }
    })

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });


</script>
</body>

</html>
